<extend name="Base/common"/>

<block name="style">
<link href="__CSS__/stylesheet.css" rel="stylesheet">
<link href="__CSS__/identify.css" rel="stylesheet">
</block>

<block name="header">
<header>
	<include file="User/header" />
</header>
</block>

<block name="body">
<div class="container main">
	<div class="user-main">
		<div class="col-xs-3">
			<include file="Identify/left_menu" />
		</div>
		<div class="col-xs-9">
			<h5>发布鉴定宝贝</h5>
			<div class="content">
				<form action="__SELF__" method="post" class="form-horizontal" enctype="multipart/form-data">
					<div class="form-group">
						<label class="col-xs-2 control-label">宝贝标题：</label>
						<div class="col-xs-8">
							<input type="text" name="title" value="" placeholder="宝贝标题" class="form-control">
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label">宝贝类目：</label>
						<div class="col-xs-8">
							<select name="category_id" class="form-control">
								<option value="">请选择分类</option>
								<volist name="category_tree" id="cate">
				     				<optgroup label="{$cate.title}">
				     					<volist name="cate._child" id="_child">
				     						<option value="{$_child.id}" <eq name="info.category_id" value="$_child.id">selected</eq>>{$_child.title}</option>
				     					</volist>
				     				</optgroup>
				     			</volist>
							</select>
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label">宝贝数量：</label>
						<div class="col-xs-8">
							<div class="input-group">
								<input type="text" name="quantity" value="" placeholder="宝贝数量" class="form-control">
								<div class="input-group-addon">个</div>
							</div>
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label">发货地：</label>
						<div class="col-xs-2">
							<select name="province_id" id="province" class="form-control">
								<option value="">省份</option>
								<volist name=":getProvinces()" id="province">
									<option value="{$province.province_id}">{$province.province}</option>
				     			</volist>
							</select>
							<script type="text/javascript">
				     		$(function(){
				     			$('#province').change(function(e){
				     				$('#city').html('<option value="">城市</option>');
				     				$('#area').html('<option value="">区县</option>');
				     				
				     				paramter = {format : 'json', province_id : $(this).val()};
				     				
				     				$.post('{:U('Api/Public/getCities')}', paramter, function(data){
				     					if (data.code == 1) {
				     						$.each(data.data, function(i, item){
				     							$('#city').append('<option value="' + item.city_id + '">' + item.city + '</option>');
				     						});
				     					}
				     				}, 'json');
				     			});
				     		});
				     		</script>
						</div>
						<div class="col-xs-2">
							<select name="city_id" id="city" class="form-control">
								<option value="">城市</option>
							</select>
							<script type="text/javascript">
				     		$(function(){
				     			$('#city').change(function(e){
				     				$('#area').html('');			     				
				     				paramter = {format : 'json', city_id : $(this).val()};
				     				
				     				$.post('{:U('Api/Public/getAreas')}', paramter, function(data){
				     					$('#area').append('<option value="">区县</option>');
				     					if (data.code == 1) {
				     						$.each(data.data, function(i, item){
				     							$('#area').append('<option value="' + item.area_id + '">' + item.area + '</option>');
				     						});
				     					}
				     				}, 'json');
				     			});
				     		});
				     		</script>
				     	</div>
				     	<div class="col-xs-2">
							<select name="area_id" id="area" class="form-control">
								<option value="">区县</option>
							</select>
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label">详细地址：</label>
						<div class="col-xs-8">
							<input type="text" name="address" value="" placeholder="详细地址" class="form-control">
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label">联系电话：</label>
						<div class="col-xs-8">
							<input type="text" name="mobile" value="" placeholder="联系电话" class="form-control">
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label">姓名：</label>
						<div class="col-xs-8">
							<input type="text" name="realname" value="" placeholder="姓名" class="form-control">
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label">宝贝描述：</label>
						<div class="col-xs-8">
							<textarea rows="6" class="form-control" name="description"></textarea>
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label">宝贝图片或视频：</label>
						<div class="col-xs-10 row">
							<div class="col-xs-2">
								<input  id="file_img" accept="image/*" name="file_img" style="display: none;">						
							</div>
							<div class="col-xs-2">
								<input type="file" id="file_video" name="file_video" accept="video/*" style="display: none;">
							</div>
							<div class="col-xs-10 files"></div>
						</div>
					</div>
					<!--  -->				
						<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>					
						<script type="text/javascript">
						//上传图片
					    /* 初始化上传插件 */
						$("#file_img").uploadify({
					        "height"          : 30,
					        "swf"             : "__STATIC__/uploadify/uploadify.swf",
					        "fileObjName"     : "download",
					        "buttonText"      : "上传图片",
					        "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
					        "width"           : 120,
					        'removeTimeout'	  : 1,
					        'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
					        "onUploadSuccess" : uploadPicture_panel,
					        'onFallback' : function() {
					            alert('未检测到兼容版本的Flash.');
					        }
					    });
						function uploadPicture_panel(file, data){
					    	var data = $.parseJSON(data);							    	
					        if(data.status){
					        	$(".files").append(
			        			"<p class='file-info'>文件名称：<span class='file-name'>"
			        			+file.name
			        			+"</span>"
			        			+"<input type='hidden' name='image_cover_id[]' value='"+data.id+"' />"
			        			+"<a class='fr' href='javascript:;'><i class='icon-remove icon-large' ></i></a></p>"
					        	);
					        } else {
					        	updateAlert(data.info);
					        	setTimeout(function(){
					                $('#top-alert').find('button').click();
					                $(that).removeClass('disabled').prop('disabled',false);
					            },1500);
					        }
					    }
		
				    /* 初始化上传插件 */
					$("#file_video").uploadify({
				        "height"          : 30,
				        "swf"             : "__STATIC__/uploadify/uploadify.swf",
				        "fileObjName"     : "download",
				        "buttonText"      : "上传视频文件",
				        "uploader"        : "{:U('File/uploadMovie',array('session_id'=>session_id()))}",
				        "width"           : 120,
				        'removeTimeout'	  : 1,
				        'multi'			  : false,
				        'fileTypeExts'	  : '*.flv; *.avi; *.wma; *.rmvb; *.rm; *.flash; *.mp4; *.mid; *.3gp;',
				        "onUploadSuccess" : uploadMovie,
				        'onFallback' : function() {
				            alert('未检测到兼容版本的Flash.');
				        }
				    });
				
					function uploadMovie(file, data){
				    	var data = $.parseJSON(data);
				        if(data.status){
				        	$(".files").append(
				        			"<p class='file-info'>文件名称：<span class='file-name'>"
				        			+file.name
				        			+"</span>"
				        			+"<input type='hidden' name='movie_id[]' value="+data.info.id+" />"
				        			+"<a class='fr' href='javascript:;'><i class='icon-remove icon-large'></i></a></p>"
				        	);
				        	
				        } else {
				        	alert(data.info);
				        	setTimeout(function(){
				                $('#top-alert').find('button').click();
				                $(that).removeClass('disabled').prop('disabled',false);
				            },1500);
				        }
				    }	
					
					$("div").delegate(".icon-remove","click",function(){
						$(this).closest('p').remove();			
					});
					
					</script>	
					<!-- -->
					<div class="form-group">
						<label class="col-xs-2 control-label"></label>
						<div class="col-xs-8">
							<label class="checkbox-inline"><input type="checkbox" value="1" name="agreement">我已经阅读并同意<a href="#" class="agreement">鉴真宝协议</a></label>
						</div>
					</div>
					<div class="form-group" style="margin-top: 30px !important;">
						<label class="col-xs-2 control-label"></label>
						<div class="col-xs-8">
							<button type="submit"  target-form="form-horizontal" class="btn ajax-post" >立即鉴定</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
</block>

<block name="script">
<script type="text/javascript">
highlight_leftnav("{:U('Identify/add')}");
highlight_subnav("{:U('Identify/index')}");
</script>
</block>